<input hidden="hidden" id="navValue" value="部门列表">

<div class="page-content">
    <div class="page-header">
        <h1>
            部门管理
            <small>
                <i class="ace-icon fa fa-angle-double-right"></i>
                部门列表
            </small>

            <label style="margin-left: 50px;">
                <button type="button" class="btn btn-purple btn-sm" onclick="location='{:url("department/add")}'">
                    <span class="ace-icon fa fa-plus-circle icon-on-right bigger-110"></span>
                    添加部门
                </button>
            </label>

            <label style="float: right">
                <form action="" method="get">
                    <input type="search" name="keywords" style="height: 35px;" class="input-sm" placeholder="部门名称" aria-controls="dynamic-table"  value={:input('get.keywords')}>

                    <button id="searchBtn" type="submit" class="dt-button buttons-collection buttons-colvis btn btn-white btn-primary btn-bold" tabindex="0" aria-controls="dynamic-table" data-original-title="" title="搜索"><span><i class="fa fa-search bigger-110 blue"></i></span></button>
                </form>
            </label>
        </h1>
    </div><!-- /.page-header -->

            <div class="row">
                <div class="col-xs-12">
                    <table id="simple-table" class="table  table-bordered table-hover">
                        <thead>
                        <tr>
                            <th class="center">
                                <label class="pos-rel">
                                    <input type="checkbox" class="ace">
                                    <span class="lbl"></span>
                                </label>
                            </th>
                            <th class="detail-col center">ID</th>
                            <th class="center">部门名称</th>
                            <th class="center">部门等级</th>
                            <th class="center">提成</th>
<!--                            <th class="center" style="width: 30%">成员组成</th>-->
                            <th class="center">状态</th>
                            <th class="center">操作</th>
                        </tr>
                        </thead>

                        <tbody>
                        {foreach $list as $val}
                        <tr  class="center">
                            <td>
                                <label class="pos-rel">
                                    <input type="checkbox" class="ace">
                                    <span class="lbl"></span>
                                </label>
                            </td>
                            <td>{$val['id']}</td>
                            <td>{$val['name']}</td>
                            <td>{$val->joinLevel->name}</td>
                            <td>{$val->joinLevel->per}%</td>

<!--                            <td><a> 查看</a></td>-->
                            <td>{$val['status']|initStatus}</td>
                            <td>
                                <div class="hidden-sm hidden-xs btn-group">

                                    <button class="btn btn-xs btn-info" onclick="location='{:url("department/detail","id=".$val->id)}'">
                                        <i class="ace-icon fa fa-pencil bigger-120"></i>
                                    </button>

                                    <button class="btn btn-xs btn-danger deleteBtn" mark="{$val['id']}">
                                        <i class="ace-icon fa fa-trash-o bigger-120"></i>
                                    </button>
                                </div>

                            </td>
                        </tr>
                        {/foreach}
                        </tbody>
                    </table>
                    {$page_html['html']}
                </div><!-- /.span -->
            </div><!-- /.row -->

            <div class="hr hr-18 dotted hr-double"></div>
            <!-- PAGE CONTENT ENDS -->
        </div><!-- /.col -->
    </div><!-- /.row -->
</div>

<script>
    $(".deleteBtn").click(function () {
        var id = $(this).attr('mark');
        layer.confirm('确定删除该部门吗？',{btn:['确定','取消']},function () {
            $.post(location.href,{id:id},function (e) {
                if(e.code == 200){
                    location.href =location.href;
                }else{
                    layer.closeAll();
                    layer.msg(e.message,{icon:5});
                }
            },'json');
            layer.closeAll();
        });
    })

</script>